/** @file
  Firmware volume driver that overrides the EFI_FIRMWARE_VOLUME_PROTOCOL
  and injects images for boot.efi/FileVault 2.

  Copyright (C) 2016 Sergey Slice. All rights reserved.<BR>
  Portions copyright (C) 2018 savvas.<BR>
  Portions copyright (C) 2006-2014 Intel Corporation. All rights reserved.<BR>
  Portions copyright (C) 2016-2018 Alex James. All rights reserved.<BR>

  This program and the accompanying materials are licensed and made
  available under the terms and conditions of the BSD License which
  accompanies this distribution. The full text of the license may be
  found at http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
  BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
  EXPRESS OR IMPLIED.

  The cursor images have not been licensed. Neither is their usage,
  their redistribution, in source or binary form, licensed, nor
  implicitly or explicitly permitted, except when required by
  applicable law.
**/

#ifndef FIRMWARE_VOLUME_INJECT_H
#define FIRMWARE_VOLUME_INJECT_H

#include <Guid/AppleFirmwareVolume.h>

typedef struct {
  EFI_GUID Guid;
  CHAR16   Name[32];
} IMAGE_ENTRY;

STATIC IMAGE_ENTRY mAppleImageTable[] = {
  {
    APPLE_ARROW_CURSOR_IMAGE_GUID,
    L"ArrowCursor"
  },
  {
    APPLE_BACK_BUTTON_SMALL_IMAGE_GUID,
    L"BackButtonSmall"
  },
  {
    APPLE_BATTERY_STATE_0_IMAGE_GUID,
    L"BatteryState0"
  },
  {
    APPLE_BATTERY_STATE_1_IMAGE_GUID,
    L"BatteryState1"
  },
  {
    APPLE_BATTERY_STATE_2_IMAGE_GUID,
    L"BatteryState2"
  },
  {
    APPLE_BATTERY_STATE_3_IMAGE_GUID,
    L"BatteryState3"
  },
  {
    APPLE_BATTERY_STATE_4_IMAGE_GUID,
    L"BatteryState4"
  },
  {
    APPLE_BATTERY_STATE_5_IMAGE_GUID,
    L"BatteryState5"
  },
  {
    APPLE_BATTERY_STATE_6_IMAGE_GUID,
    L"BatteryState6"
  },
  {
    APPLE_BEGIN_BOOT_BUTTON_IMAGE_GUID,
    L"BeginBootButton"
  },
  {
    APPLE_BEGIN_STICKY_BOOT_BUTTON_IMAGE_GUID,
    L"BeginStickyBootButton"
  },
  {
    APPLE_CONTINUE_BUTTON_SMALL_IMAGE_GUID,
    L"ContinueButtonSmall"
  },
  {
    APPLE_BOOT_NAME_LABEL_IMAGE_GUID,
    L"EfiBootNameLabel"
  },
  {
    APPLE_BROKEN_BOOT_IMAGE_GUID,
    L"IconBrokenBoot"
  },
  {
    APPLE_FIREWIRE_HD_IMAGE_GUID,
    L"IconFireWireHD"
  },
  {
    APPLE_GENERIC_CD_IMAGE_GUID,
    L"IconGenericCD"
  },
  {
    APPLE_GENERIC_EXTERNAL_HD_IMAGE_GUID,
    L"IconGenericExternalHardDrive"
  },
  {
    APPLE_INTERNAL_HD_IMAGE_GUID,
    L"IconInternalHD"
  },
  {
    APPLE_NETBOOT_IMAGE_GUID,
    L"IconNetBoot"
  },
  {
    APPLE_NETWORK_RECOVERY_IMAGE_GUID,
    L"IconNetworkRecovery"
  },
  {
    APPLE_NETWORK_VOLUME_IMAGE_GUID,
    L"IconNetworkVolume"
  },
  {
    APPLE_PASSWORD_LOCK_IMAGE_GUID,
    L"IconPasswordLock"
  },
  {
    APPLE_SD_IMAGE_GUID,
    L"IconSD"
  },
  {
    APPLE_SELECTED_IMAGE_GUID,
    L"IconSelected"
  },
  {
    APPLE_USB_HD_IMAGE_GUID,
    L"IconUsbHD"
  },
  {
    APPLE_WIRELESS_SMALL_IMAGE_GUID,
    L"IconWirelessSmall"
  },
  {
    APPLE_LOGO_IMAGE_GUID,
    L"ImageAppleLogo"
  },
  {
    APPLE_PASSWORD_EMPTY_IMAGE_GUID,
    L"ImagePasswordEmpty"
  },
  {
    APPLE_PASSWORD_FILL_IMAGE_GUID,
    L"ImagePasswordFill"
  },
  {
    APPLE_PASSWORD_PROCEED_IMAGE_GUID,
    L"ImagePasswordProceed"
  },
  {
    APPLE_LOGO_1394_IMAGE_GUID,
    L"Logo1394"
  },
  {
    APPLE_LOGO_THUNDERBOLT_IMAGE_GUID,
    L"LogoThunderbolt"
  },
  {
    APPLE_CLOCK_IMAGE_GUID,
    L"Clock"
  },
  {
    APPLE_ERROR_GLOBE_BORDER_IMAGE_GUID,
    L"ErrorGlobeBorder"
  },
  {
    APPLE_ERROR_GLOBE_TITLE_IMAGE_GUID,
    L"ErrorGlobeTile"
  },
  {
    APPLE_ERROR_TRIANGLE_IMAGE_GUID,
    L"ErrorTriangle"
  },
  {
    APPLE_GLOBE_BORDER_IMAGE_GUID,
    L"GlobeBorder"
  },
  {
    APPLE_GLOBE_MASK_IMAGE_GUID,
    L"GlobeMask"
  }
};


STATIC UINT8 mAppleArrowCursorImage[] = {
    0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
    0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x04, 0x00, 0x00, 0x00, 0x4A, 0x7E, 0xF5,
    0x73, 0x00, 0x00, 0x01, 0x29, 0x49, 0x44, 0x41, 0x54, 0x38, 0x4F, 0x8D, 0xD4, 0x3D, 0x4B, 0x03,
    0x41, 0x10, 0xC6, 0xF1, 0xFF, 0xDE, 0x8B, 0xB9, 0xBB, 0x80, 0xE2, 0x4B, 0xD4, 0x80, 0x1A, 0xD0,
    0x22, 0xE1, 0x2C, 0x44, 0xAB, 0x14, 0xE9, 0x4D, 0xAF, 0x36, 0x5A, 0xF8, 0x79, 0x34, 0x60, 0x69,
    0x23, 0x76, 0x62, 0x23, 0xB6, 0x5A, 0x49, 0x2A, 0x3B, 0xC1, 0x26, 0x8D, 0x8D, 0xB1, 0xF3, 0x5B,
    0xEC, 0x63, 0xB1, 0x9C, 0x68, 0x72, 0x47, 0x76, 0xB6, 0x9D, 0x1F, 0x33, 0xCB, 0xCC, 0x2E, 0x00,
    0x18, 0x0C, 0x06, 0xEF, 0x30, 0x84, 0xC4, 0x44, 0x04, 0x7E, 0xC8, 0x10, 0x52, 0x97, 0xC6, 0xE7,
    0xA4, 0x84, 0x3E, 0xC4, 0x50, 0xA3, 0x29, 0x49, 0xC3, 0x63, 0x32, 0x1F, 0x62, 0x48, 0xD9, 0x91,
    0x72, 0xC9, 0xFA, 0x11, 0x43, 0x46, 0x5B, 0xC2, 0x9B, 0x18, 0x32, 0x3A, 0x12, 0xDE, 0xE4, 0x0F,
    0xF0, 0x23, 0xFF, 0x80, 0x0F, 0x99, 0x00, 0xB3, 0xC9, 0x14, 0x98, 0x45, 0x4A, 0x80, 0x23, 0xAF,
    0x47, 0x24, 0x04, 0x55, 0xC0, 0xBA, 0x34, 0x97, 0x5A, 0x1C, 0x16, 0x89, 0xA6, 0x6B, 0xFC, 0x82,
    0x5C, 0xEF, 0xA3, 0x5C, 0xE8, 0xF2, 0xEB, 0xFE, 0x81, 0x33, 0xFA, 0xEC, 0xB1, 0x4C, 0x5C, 0x09,
    0x72, 0xC9, 0xDE, 0x3D, 0x5E, 0x8C, 0x5D, 0x0D, 0x7A, 0x74, 0x68, 0x52, 0x2F, 0xBB, 0x85, 0x9B,
    0xB4, 0x95, 0xE5, 0x94, 0x13, 0xD9, 0x5C, 0xE8, 0xEA, 0xE3, 0x6D, 0x40, 0xA3, 0x6A, 0x19, 0x0D,
    0x29, 0xDB, 0xB2, 0xF4, 0xE9, 0xD2, 0x7D, 0xBA, 0x1D, 0x7C, 0xA2, 0x5C, 0xDF, 0x43, 0x56, 0xCB,
    0xDA, 0x71, 0xA0, 0xC6, 0x3A, 0xBB, 0xB4, 0x69, 0xB2, 0x45, 0xCF, 0xD5, 0x90, 0x65, 0x83, 0x5A,
    0x15, 0x08, 0xC9, 0x58, 0x62, 0x9E, 0x84, 0x05, 0x3A, 0xCF, 0x37, 0xB2, 0xB2, 0x2F, 0xD7, 0x6C,
    0x56, 0x01, 0x47, 0x22, 0x42, 0x02, 0xE6, 0x58, 0xE3, 0x80, 0x3E, 0x87, 0xEC, 0xB3, 0x52, 0xD5,
    0x52, 0x81, 0xC0, 0x10, 0x90, 0xD2, 0xA0, 0x45, 0x8B, 0x06, 0x69, 0xD9, 0xD0, 0x26, 0xC3, 0x10,
    0x10, 0x93, 0x90, 0x10, 0xFB, 0xBE, 0xF0, 0xE2, 0x07, 0xF1, 0x4C, 0xF6, 0x88, 0x1F, 0xEA, 0xC7,
    0xA7, 0xF4, 0x03, 0x23, 0x37, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42,
    0x60, 0x82
};

STATIC UINT8 mAppleArrowCursor2xImage[] = {
    0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
    0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x50, 0x08, 0x04, 0x00, 0x00, 0x00, 0xE6, 0x28, 0x7E,
    0xA2, 0x00, 0x00, 0x03, 0x3B, 0x49, 0x44, 0x41, 0x54, 0x68, 0xDE, 0xED, 0xD8, 0x4F, 0x68, 0x1C,
    0x65, 0x1C, 0x87, 0xF1, 0x67, 0xDE, 0x99, 0xDD, 0x99, 0xDD, 0xC9, 0x26, 0xBB, 0xC9, 0x36, 0x69,
    0xB2, 0xE9, 0x9F, 0xDD, 0x54, 0x23, 0x69, 0x8C, 0x92, 0xA0, 0x6D, 0x59, 0x52, 0x6C, 0x75, 0xDB,
    0x0A, 0x25, 0x88, 0x67, 0xEB, 0xA1, 0x08, 0x42, 0x11, 0xF1, 0x20, 0x5E, 0x5A, 0xC8, 0x25, 0xF4,
    0x20, 0xE9, 0xA5, 0xA0, 0x47, 0x0F, 0xA2, 0x55, 0x9B, 0x1A, 0x2F, 0x2A, 0x42, 0xAF, 0x5E, 0x8A,
    0xB4, 0x45, 0xD4, 0x5E, 0xB4, 0x78, 0xA8, 0xD0, 0x88, 0x54, 0xB4, 0x69, 0xD7, 0x84, 0x98, 0xFD,
    0x7A, 0x98, 0x31, 0xA4, 0x24, 0x4D, 0x42, 0x76, 0x26, 0xA0, 0xCC, 0x73, 0x9A, 0xDB, 0x87, 0x99,
    0x7D, 0xF7, 0x9D, 0xF7, 0x37, 0x90, 0xF4, 0xFF, 0xCA, 0xC2, 0x92, 0x83, 0x85, 0xB5, 0x55, 0x9C,
    0xC1, 0x6E, 0x4C, 0x9D, 0x77, 0xB1, 0x31, 0xF1, 0xA3, 0x16, 0x06, 0x07, 0x57, 0x5A, 0xB8, 0x74,
    0xC2, 0x27, 0x85, 0x1D, 0x37, 0x69, 0x61, 0xE3, 0x91, 0x93, 0xA4, 0xB9, 0xE9, 0x6A, 0x8E, 0x74,
    0xDC, 0xA4, 0x45, 0x0A, 0x9F, 0x0E, 0x29, 0x20, 0xF7, 0xB5, 0xC6, 0x4D, 0x1A, 0xD2, 0xB4, 0xB2,
    0x5D, 0x92, 0xFE, 0x94, 0x54, 0xFF, 0x2C, 0x6E, 0xD2, 0xE0, 0x92, 0x67, 0x87, 0x24, 0x1D, 0xDA,
    0x12, 0xD2, 0xE0, 0xD1, 0xCE, 0x6E, 0x49, 0x42, 0x87, 0x03, 0x32, 0xD6, 0x07, 0x1B, 0x80, 0xE5,
    0x00, 0xDC, 0x0A, 0x32, 0x00, 0x2B, 0xFF, 0x82, 0xE8, 0xB0, 0xEE, 0x4A, 0xAA, 0x7F, 0x1A, 0x17,
    0xB9, 0x02, 0x44, 0xCF, 0xC5, 0x4A, 0xAE, 0x02, 0x2E, 0x91, 0x97, 0xE2, 0x20, 0x57, 0x05, 0xE3,
    0x24, 0x1F, 0x02, 0xA2, 0x5A, 0x40, 0x4E, 0x45, 0x4D, 0x3E, 0x14, 0x44, 0x35, 0xCD, 0x4A, 0xAA,
    0x4F, 0xF5, 0x47, 0xBA, 0xE1, 0xAD, 0x01, 0x2E, 0x91, 0x17, 0xA3, 0x24, 0xD7, 0x04, 0xD1, 0x91,
    0xC8, 0xC9, 0x75, 0xC0, 0x25, 0xF2, 0x93, 0xA8, 0xC8, 0x75, 0x41, 0x74, 0x34, 0x52, 0x72, 0x03,
    0x20, 0x3A, 0xAA, 0x7B, 0x92, 0xEA, 0x1F, 0x47, 0x41, 0x6E, 0x08, 0x5C, 0x22, 0x3F, 0x6A, 0x9E,
    0xDC, 0x20, 0x88, 0x9E, 0xD7, 0xFD, 0x48, 0xC8, 0x35, 0xC1, 0x9F, 0xB5, 0xB2, 0xFA, 0x85, 0x21,
    0x9F, 0x14, 0x26, 0x42, 0xF0, 0x35, 0x8D, 0x85, 0x57, 0xE3, 0x5A, 0xAD, 0xF9, 0x0F, 0x9E, 0xF1,
    0x36, 0x7F, 0x8F, 0x2B, 0xC0, 0x37, 0xB5, 0xA8, 0xAF, 0xC2, 0xEB, 0x36, 0xDD, 0x97, 0x74, 0xF6,
    0xF5, 0x91, 0x17, 0x9E, 0x3E, 0x7E, 0xE0, 0xD8, 0xE8, 0xB3, 0xB5, 0xEA, 0x8B, 0xC3, 0x27, 0xFB,
    0x27, 0x76, 0x8C, 0x64, 0x71, 0x22, 0x02, 0xCF, 0xA8, 0x21, 0xE9, 0x6F, 0x55, 0x42, 0xF2, 0x43,
    0x49, 0x3F, 0x4D, 0x73, 0x90, 0xFD, 0x8C, 0xF0, 0x04, 0x03, 0x54, 0xE8, 0xA1, 0x40, 0x26, 0x22,
    0x70, 0x42, 0x92, 0xF4, 0xC7, 0x4D, 0xE9, 0x7C, 0x08, 0xEE, 0x93, 0xB4, 0x38, 0x3B, 0x5A, 0x65,
    0x2F, 0x8F, 0x52, 0x66, 0x27, 0xDD, 0x74, 0x90, 0xC3, 0x8D, 0xE4, 0x91, 0x9E, 0x93, 0x24, 0x5D,
    0xBF, 0xF0, 0xD6, 0x29, 0xE9, 0x37, 0x99, 0x90, 0xBC, 0x22, 0xE9, 0x87, 0x71, 0xCA, 0x74, 0x53,
    0xA4, 0x40, 0x1B, 0x2D, 0x78, 0xA4, 0x36, 0x7F, 0x46, 0x5F, 0x06, 0x4A, 0xD2, 0xD5, 0xF7, 0xA8,
    0x51, 0xBB, 0x73, 0x5D, 0x3A, 0x15, 0x82, 0xAF, 0x48, 0x9A, 0xBB, 0x41, 0x2F, 0xED, 0xB4, 0xE0,
    0xE1, 0x92, 0xC2, 0x69, 0x66, 0x24, 0x58, 0x76, 0x88, 0x92, 0xAE, 0xBE, 0xC3, 0x28, 0x07, 0xA8,
    0x7E, 0x71, 0x46, 0xBA, 0x16, 0x82, 0x96, 0x66, 0x24, 0x7D, 0x3D, 0x46, 0x1E, 0x0F, 0x07, 0x83,
    0x69, 0x6E, 0xEC, 0x31, 0xB8, 0x14, 0xD8, 0x25, 0xA9, 0x71, 0x6D, 0x92, 0xA7, 0x78, 0x92, 0x41,
    0x86, 0x5A, 0xF7, 0xCF, 0xCD, 0x48, 0x07, 0x43, 0xF2, 0x9C, 0xA4, 0xBB, 0xD3, 0xB4, 0xE3, 0x61,
    0x47, 0x75, 0x10, 0xEE, 0xD5, 0xE2, 0x77, 0xE3, 0x0C, 0xF1, 0x18, 0x15, 0x76, 0xD1, 0xC7, 0xE0,
    0x8D, 0x77, 0xA5, 0x8B, 0x21, 0x58, 0xD2, 0xBC, 0x1A, 0xF3, 0x93, 0x03, 0xB4, 0x6C, 0x7E, 0x6D,
    0x3E, 0x78, 0xD4, 0xCF, 0xD1, 0xF5, 0xE3, 0x1B, 0xEC, 0xA1, 0x42, 0x2F, 0x9D, 0x14, 0xD9, 0x4E,
    0xDF, 0xCB, 0x87, 0x1A, 0xF3, 0x7F, 0xA9, 0x18, 0x92, 0x97, 0x25, 0xCD, 0x9C, 0xA5, 0x0D, 0x77,
    0xF3, 0x3B, 0xCC, 0xF2, 0x61, 0x26, 0x4B, 0x81, 0x2E, 0xBA, 0xE9, 0xA4, 0x40, 0x0E, 0x9F, 0x3C,
    0x25, 0x06, 0x6E, 0x7F, 0x29, 0x4D, 0xC8, 0xE8, 0x55, 0x7D, 0x23, 0x49, 0x5A, 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0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0xFA, 0xEF, 0xF5, 0x0F,
    0x6B, 0xE8, 0x96, 0x73, 0x50, 0x00, 0x9A, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
    0xAE, 0x42, 0x60, 0x82
};

EFI_STATUS
EFIAPI
InitializeFirmwareVolume2 (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  );

#endif // FIRMWARE_VOLUME_INJECT_H
